package com.juc.callable.callable8;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Test3 {

	/**
	 * 
	 * execute方法出现异常后直接打印堆栈信息，而submit方法
	 * 可以捕获继续
	 */
	public static void main(String[] args) {
		try {
			ThreadPoolExecutor executor = new ThreadPoolExecutor(50, Integer.MAX_VALUE, 5, TimeUnit.SECONDS, new LinkedBlockingDeque<Runnable>());
		    Future<String> future = executor.submit(new Callable<String>() {
	
				@Override
				public String call() throws Exception {
					Integer.parseInt("a");
					return "我是返回值";
				}
			});
			System.out.println(future.get());
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println("能捕获异常");
		}
	}
}
